#include <iostream>

using namespace std;

struct custormer
{
    char fullname[35];
    double payment;
};

class Stack
{
private:
    enum {num=20};
    custormer custormers[num];
    int top;

public:
    Stack();
    bool null() const;
    bool full() const;
    bool add(const custormer &item);
    bool data(custormer &item);

};

Stack::Stack()
{
    top=0;
}
bool Stack::null() const
{
    return top==0;
}
bool Stack::full() const
{
    return top==num;
}
bool Stack::add(const custormer &item)
{
    if (top<num)
    {
        custormers[top++]=item;
        return true;
    }
    else return false;
}

bool Stack::data(custormer &item)
{
    if (top>0)
    {
        item=custormers[--top];
        return true;
    }
    else return false;
}


int main()
{
    Stack s;
    custormer c;
    float payment=0;
    char select;
    cout<<"You can select 'a' : add or 'd' : data:"<<endl;
    while (cin.get(select))
    {
        while(cin.get()!='\n') continue;
        if (select=='a')
        {
            cout<<"Enter Name:";
            cin.getline(c.fullname,20);
            cout<<"EnteR Amount:";
            cin>>c.payment;
            s.add(c);
            cout<<endl;
            cout<<"Successfully added!!!"<<endl;
            cout<<endl;
        }
        if (select=='d')
        {
            s.data(c);
            payment=c.payment+payment;
            cout<<"Name:"<<c.fullname<<endl;
            cout<<"Amount: "<<c.payment<<endl;
            cout<<"Total amount:"<<payment<<endl;
        }
    }


    return 0;
}
